import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Mainpage from "../views/Mainpage.vue"
import Search from "../views/Search.vue"
import Information from "../views/Information.vue"
import Login from "../views/Login.vue"
import Portal from "../views/Portal.vue"
import Passage from "../views/Passage.vue"
import Manage from "../views/Manage.vue"
import vueToPdf from 'vue-to-pdf'//用于导出文献pdf

Vue.use(VueRouter)
Vue.use(vueToPdf)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
//防止重复跳转同一个路由

const routes = [
  { path: '/', redirect: "/Home" },
  {
    path: '/Home', component: Home, redirect: "/Mainpage", children: [
      { path: '/Mainpage', component: Mainpage },
      { path: "/Search", component: Search },
      { path: "/Information/:id", component: Information },
      { path: "/Passage/:id", component: Passage },
      { path: "/Portal", component: Portal },
    ]
  },
  { path: "/Login", component: Login },
  { path: "/Manage", component: Manage }
]

const router = new VueRouter({
  routes
})

export default router
